package com.dg.cuckoo.admin.action.basicInformation.label.setLabel;

import com.dg.cuckoo.admin.dto.basicInformation.label.TwoLabelDto;
import com.dg.cuckoo.admin.service.TwoLabelService;
import com.dg.cuckoo.admin.vo.FreeVo;
import com.dg.cuckoo.common.utils.PageModel;
import com.dg.cuckoo.core.BaseController;
import com.dg.cuckoo.core.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 基础资料-标签管理-标签设置-二级标签
 */
@RestController
@RequestMapping("/basicInformation/label/setLabel/twoLabel")
public class TwoLabel extends BaseController {

    @Autowired
    private TwoLabelService service;

    /**
     * 查看页面
     */
    @PostMapping("selectView")
    public JsonResult<List<FreeVo>> selectView(){
        List<FreeVo> data = service.selectView();
        return new JsonResult<>(OK,data);
    }

    /**
     * 新建
     */
    @PostMapping("save")
    public JsonResult<Void> save(TwoLabelDto dto){
        service.save(dto);
        return new JsonResult<>(OK);
    }

    /**
     * 删除
     */
    @PostMapping("delect/{id}")
    public JsonResult<Void> delect(@PathVariable String id){
        service.delect(id);
        return new JsonResult<>(OK);
    }

    /**
     * 点击查看信息
     */
    @PostMapping("select/{id}")
    public JsonResult<TwoLabelDto> select(@PathVariable String id){
        TwoLabelDto data = service.select(id);
        return new JsonResult<>(OK,data);
    }

    /**
     * 点击一级标签下拉选弹出信息
     */
    @PostMapping("openSelect")
    public JsonResult<List<TwoLabelDto>> openSelect(String name){
        List<TwoLabelDto> data = service.openSelect(name);
        return new JsonResult<>(OK,data);
    }

    /**
     * 分页
     * @param page 页
     * @param pageSize 页数
     * @return
     */
    @PostMapping("page/{page}/{pageSize}")
    public JsonResult<PageModel> page(@PathVariable Integer page, @PathVariable Integer pageSize){
        PageModel data = service.page(page, pageSize);
        return new JsonResult<>(OK,data);
    }

    /**
     * 修改
     */
    @PostMapping("update/{id}")
    public JsonResult<Void> update(@PathVariable String id,TwoLabelDto dto){
        service.update(id,dto);
        return new JsonResult<>(OK);
    }



}
